#include <iostream>
using namespace std;

int main() {
    int year, month, day;
    cin >> year >> month >> day;

    int MonthDay1_N[13] = { 0, 31,59,90,120,151,181,212,243,273,304,334,365 };

    int nday = MonthDay1_N[month - 1];
    nday += day;

    if (month > 2 && ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)))
    {
        nday += 1;
    }
    cout << nday << endl;
}
